package DataStructureAndAlgorithm.AcWing_每日一题.数学.推公式;
import java.util.Scanner;
//链接：https://www.acwing.com/problem/content/3785/

//对整个求和公式进行演算，最后得出在结果中，所有的x坐标对答案的贡献为n*(Xi^2) - (X1 + X2 + ... +Xn)^2
//同理，y坐标的贡献也是一样，所以，对两个贡献进行加和操作即可
public class AcWing_3782 {

    static int N = 100010;
    static int n;
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        long[] x = new long[N];
        long[] y = new long[N];
        n = in.nextInt();
        for (int i = 0; i < n; i++){
            x[i] = in.nextLong();
            y[i] = in.nextLong();
        }

        long res = get(x) + get(y);
        System.out.println(res);
    }

    static long get(long[] num){
        long s1 = 0;
        long s2 = 0;
        for (int i = 0; i < n; i++){
            s1 += num[i] * num[i];
            s2 += num[i];
        }

        return n * s1 - (s2 * s2);
    }
}
